//
//  VideoView.h
//  Rail
//
//  Created by huyuchen on 2018/3/15.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "BMCustomButton.h"
@class VideoView;

typedef NS_ENUM(NSInteger,PlayVideoStatus){
    PlayVideoStatusUnknown = 0,
    PlayVideoStatusPlaying,   //
    PlayVideoStatusPause,
    PlayVideoStatusStop,
};

#define kVideoViewH SCREEN_WIDTH*230/414

NS_ASSUME_NONNULL_BEGIN

@interface VideoStreamModel : NSObject
@property (nonatomic, copy) NSString *title;
@property (nonatomic, assign) BOOL isCurrentSelected;
@property (nonatomic, assign) int channel;
@property (nonatomic, assign) int streamType;
@end

@interface VideoPlayView : UIView
//码流
@property (nonatomic, strong) UIView *playContainer;
@property (nonatomic, strong) NSMutableArray *streamArray;
@property (nonatomic, weak) VideoView *videoView;
@property (nonatomic, assign) int index;
@property (nonatomic, assign) PlayVideoStatus playStatus;
@property (nonatomic, strong) SelectVideoDeviceModel *model;

@property (nonatomic, assign) BOOL isFullScreen;
@property (nonatomic, assign) BOOL isVoiceMuted;
@property (nonatomic, assign) BOOL isShowToolBar;

- (void)addPopover;
- (void)removePopover;
- (void)moveStreamTableView;
@end

@interface VideoToolBar : UIView
@property (nonatomic, weak) VideoView *videoView;
@property (nonatomic, weak) VideoPlayView *videoPlayView;

@property (nonatomic, copy) void(^BlockClickStreamBtn)();

@property (nonatomic, strong) UIView *funcContainer;
@property (nonatomic, strong) UIButton *playBtn;
@property (nonatomic, strong) UIButton *voiceBtn;
@property (nonatomic, strong) UIButton *fullScreenBtn;
@property (nonatomic, strong) UIButton *splitScrrenBtn;
@property (nonatomic, strong) BMCustomButton *playRateBtn;

@property (nonatomic, assign) int index;
@property (nonatomic, strong) VideoStreamModel *model;
@property (nonatomic, strong) VideoIpTypeModel *ipType;
@end

@protocol VideoViewDelegate;
@interface VideoView : UIView
//代理
@property (nonatomic, weak) id<VideoViewDelegate> delegate;
@property (nonatomic, strong) NSMutableArray *playViewArray;
@property (nonatomic, assign) BOOL isSplited;
@property (nonatomic, assign) BOOL isFullScreen;

- (VideoPlayView *)videoPlayViewWithIndex:(int)index;
- (void)setPlayStatus:(PlayVideoStatus)status withIndex:(int)index;

- (void)toFullScreenWithVideoPlayView:(VideoPlayView *)playView completion:(void(^)(BOOL finished))completion;
- (void)toNormalScreenWithSuperView:(UIView *)superView videoPlayView:(VideoPlayView *)playView completion:(void(^)(BOOL finished))completion;

- (void)toSplitedScreen;
- (void)cancelSplitedScreen:(UIView *)superView;

- (void)setupSinglePlayView;
- (void)setupSplitedPlayView;

- (NSInteger)videoPlayCount;
- (BOOL)isPlayingWithPlayViewIndex:(NSInteger)index;
- (BOOL)isVoiceMutedWithPlayViewIndex:(NSInteger)index;
- (NSInteger)clickIndexWithCurrentVideoPlayView;

@end

@protocol VideoViewDelegate <NSObject>
@required
//点击了 退出全屏
- (UIView *)cancelFullScreenWithVideoView:(VideoView *)view;
@optional
//点击了 屏幕中的播放按钮
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView clickPlayWithIndex:(NSInteger)index count:(NSInteger)count;
//点击了 功能条播放暂停按钮
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView clickPlayPauseButton:(UIButton *)btn playStatus:(PlayVideoStatus)status;
//点击了 功能条静音按钮
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView clickVoiceButton:(UIButton *)btn isVoiceMuted:(BOOL)isVoiceMuted;
//点击了 功能条全屏按钮
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView clickFullScreenButton:(UIButton *)btn isFullScreen:(BOOL)isFullScreen;
//点击了 功能条分屏按钮
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView clickSplitScreenButton:(UIButton *)btn isSplitedScreen:(BOOL)isSplitedScreen;
//点击了 码流选择按钮
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView videoPlayIndex:(int)index clickStreamSelectButton:(UIButton *)btn;
//点击了 码流
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView videoPlayIndex:(int)index streamTypeSelectWithIndexPath:(NSIndexPath *)indexPath stream:(VideoStreamModel *)stream ipType:(VideoIpTypeModel *)ipType;
//点击了 分屏状态下弹出工区选择监控
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView splitedScreenSelectVideoWithIndex:(NSInteger)index;
//分屏状态下点击退出 关闭其他播放
- (void)videoView:(VideoView *)view videoPlayView:(VideoPlayView *)playView stopOtherPlayWithSplitedStateIndex:(int)index;
@end

NS_ASSUME_NONNULL_END
